package com.example.mr5.money.main.express;/**
 * Created by Mr.5
 * Date：2016/10/6.
 * Time：23:06
 */

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.mr5.money.R;
import com.example.mr5.money.model.ExpressRecord;

import java.util.List;

/**
 * Created by Mr.5 
 * Date：2016/10/6.
 * Time：23:06
 */
public class ExpressRecordAdapter extends BaseAdapter {

    private Context context;
    private List<ExpressRecord> list;

    public ExpressRecordAdapter(Context context,List<ExpressRecord> list){
        this.context = context;
        this.list = list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null){
            holder = new ViewHolder();
            convertView = View.inflate(context, R.layout.item_express_record,null);
            holder.company = (TextView) convertView.findViewById(R.id.company);
            holder.number = (TextView) convertView.findViewById(R.id.express_num_record);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.company.setText(list.get(position).getCompany());
        holder.number.setText(list.get(position).getNumber());
        return convertView;
    }

    private class ViewHolder{
        private TextView company;
        private TextView number;
    }
}
